import React, { Component } from 'react';
import {getQueryString} from '../utils/util';
import { Flex, WingBlank, Button, Steps} from 'antd-mobile';
import { Link } from 'react-router-dom';

import 'antd-mobile/lib/flex/style/css';
import 'antd-mobile/lib/steps/style/css';

import '../allStyle.css';

class Examine extends Component{
    state = {
      status : 0,
      result: 1,
      resultStatus:'通过',
      resultMsg:'审核通过'
    }
    componentDidMount(){
        let title = getQueryString('title');
        if(title == null){
            document.title = '等待审核';
        }else{
            document.title = title;
        }
        let status = getQueryString('status');
        let remark = getQueryString('remark');

        let examine = localStorage.getItem('examine');
        if(examine !== null){
            this.setState({
                status : 1
            });
        }else{
            localStorage.setItem('examine', 'comme in examine');
        }
        if(status == 1){
            this.setState({
                status : 2
            });
        }else if(status == -1){
            this.setState({
                status : 2,
                result : 0,
                resultStatus: '未通过',
                resultMsg: remark?remark:'审核未通过'
            });
        }
    }
    render(){
        const Step = Steps.Step;
        return(
          <div style={{height:'100%'}}>
            <Flex direction='column' justify='center' align='center' style={{height:'80%'}}>
                <Flex style={{ width:'auto'}} align='center'>
                    <Steps size="big" current={this.state.status} style={{ backgroundColor:'wihte'}}>
                        <Step title="申请已提交" description="等待审核" />
                        <Step title="正在审核中" description="请耐心等待...." />
                        {
                          this.state.result == 0?
                            <Step status="error" title={this.state.resultStatus} description={this.state.resultMsg} />
                            :
                            <Step title={this.state.resultStatus} description={this.state.resultMsg} />
                        }
                    </Steps>
                </Flex>
            </Flex>
            <WingBlank>
                    {
                      this.state.status == 2
                      ?
                          <Link to='/Login'>
                                <Button  style={{marginTop:'0.8rem'}} type="primary">重新申请</Button>
                          </Link>
                      :
                          <Button disabled style={{marginTop:'0.8rem'}} type="primary">重新申请</Button>
                    }

            </WingBlank>
          </div>
        )
    }
}
export default Examine;
